//
// Created by f on 2022/3/17.
//

#ifndef HPA_GRID_MAP_H
#define HPA_GRID_MAP_H

#include "map_base.h"

class GridMap: public MapBase{
public:
    GridMap(const float &center_x, const float &center_y, const float &center_yaw,
            const float &grid_dim, const int &half_x_size, const int &half_y_size, const int& layer_id);

    /**
     * 初始化一个空的地图对象，用于加载储存的地图文件
     * @param layer_id
     */
    GridMap(const int& layer_id);

    ~GridMap() = default;

    bool AddPoint(const double& x, const double& y) override;

    uint8_t GetValue(const double& x, const double& y) override;

    bool SaveMap(const std::string& save_path,  const std::string& save_type) override;

    bool LoadMap(const std::string& load_path,  const std::string& load_type) override;

    void Clear() override;

    bool toCVMat(cv::Mat &m) override;

    double Center_x() override;
    double Center_y() override;
    double Center_yaw() override;
    double Dim_x() override;
    double Dim_y() override;
    int LayerID() override;

private:
    double center_x_, center_y_, center_yaw_; //这三个参数描述了地图坐标系和世界坐标系的关系
    double grid_dim_; //地图的最小单元的边长是多少米
    double half_x_size_, half_y_size_; //x、y向网格数量
    cv::Mat grids_;
    int layer_id_;
};

#endif //HPA_GRID_MAP_H
